<script type="text/javascript">
$(function() {
$('a.delimgbutton').click(function(){
	
	//Save the link in a variable called element
	var element = $(this);

	//Find the id of the link that was clicked
	var del_id = element.attr("id");

	//Built a url to send
	var info = 'id=' + del_id + '&tabla=images_news';
	
	if(confirm("¿ Esta seguro que desea eliminar esta Imagen ?")){
 		$.ajax({
	   		type: "POST",
	   		url: "eliminar.php",
	   		data: info,
	   		success: function(){
	   		}
 		});
    
	    $(this).parents('span.imgrecord').animate({ backgroundColor: "#fbc7c7" }, "fast")
		.animate({ opacity: "hide" }, "slow");
 	}
	return false;
});
});
</script>
<?php
require_once '../includes/includes.php';
conexion();

$id_new = $_GET[id];

$con = mysql_query("SELECT * FROM images_news where id_news = $id_new");



if(mysql_num_rows($con) != 0){
			// hay mas de una


			if(mysql_num_rows($con)==1){
				//un solo registro
				$cat = mysql_fetch_array($con);

				$v_imagen = explode('.',$cat[url]);
				$id_imagen = $v_imagen[0];

				$url = '../'.$cat[folder].$id_new.'_'.$cat[url];
				
				echo '<span style="margin-left:15px"  class="imgrecord" >';						
						echo '<img src="'.$url.'" style=" border: solid 1px #DDD;" />';
						echo '<a id="'.$id_imagen.'" href="#" class="delimgbutton">';
							echo '<img src="images/delete_16.png" alt="Eliminar Imagen" />';
						echo '</a>';
				echo '</span>';

			}
			else{ 
				//conjunto de registros
				while($cat=mysql_fetch_array($con)){
					
					$v_imagen = explode('.',$cat[url]);
					$id_imagen = $v_imagen[0];

					$url = '../'.$cat[folder].$id_new.'_'.$cat[url];
					

					echo '<span style="margin-left:15px;" class="imgrecord" >';						
						echo '<img src="'.$url.'" style=" border: solid 1px #DDD;" />';
						echo '<a id="'.$id_imagen.'" href="#" class="delimgbutton">';
							echo '<img src="images/delete_16.png" alt="Eliminar Imagen" />';
						echo '</a>';
					echo '</span>';
					
				}			
			}
		}
		else{

			echo 'Todavía no se cargaron imágenes';
		}

?>